﻿using System;
using System.Collections.Generic;
using System.Text;
using Fcdbas.Core.WCF.TransFile.Contracts.Enums;
using System.IO;

namespace Fcdbas.Core.WCF.TransFile.Client
{
    /// <summary>
    /// 构建客户端上传参数
    /// </summary>
    public class UpLoadFileInfo
    {
        public UpLoadFileInfo(string filePath)
        {
            init(filePath, string.Empty, SpaceType.Other);
        }

        public UpLoadFileInfo(string filePath, string fileTitle, SpaceType spaceType)
        {
            init(filePath, fileTitle, spaceType);
        }

        private void init(string filePath, string fileTitle, SpaceType spaceType)
        {
            if (File.Exists(filePath))
            {
                FileInfo info = new FileInfo(filePath);
                FileTitle = string.IsNullOrEmpty(fileTitle) ? info.Name : fileTitle;
                Extension = info.Extension;
                FileSize = info.Length;
                LocalPath = filePath;
            }
            this.SpaceType = spaceType;
        }

        /// <summary>
        /// 本地路径
        /// </summary>
        public string LocalPath { get; set; }

        ///// <summary>
        ///// 文件名称
        ///// </summary>
        //public string FileName { get; set; }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string FileTitle { get; set; }

        /// <summary>
        /// 文件扩展名
        /// </summary>
        public string Extension { get; set; }

        /// <summary>
        /// 文件大小
        /// </summary>
        public long FileSize { get; set; }

        /// <summary>
        /// 是否由客户端构建路径
        /// </summary>
        public bool IsClientBuilderPath { get; set; }

        /// <summary>
        /// 客户端构建的路径
        /// </summary>
        public string ClientBuilderPath { get; set; }

        /// <summary>
        /// 文件类型
        /// </summary>
        public SpaceType SpaceType { get; set; }

        /// <summary>
        /// 用户编码
        /// </summary>
        public string CustomFolder { get; set; }

        /// <summary>
        /// 文件唯一标识
        /// </summary>
        public string Identifier { get; set; }

        /// <summary>
        /// 操作类型
        /// </summary>
        public ToolType ToolType { get; set; }

        public UpLoadFileInfo Clone()
        {
            return this.MemberwiseClone() as UpLoadFileInfo;
        }

    }
}
